package com.emm.yixun.openapi.hander;

import java.util.List;

import com.emm.yixun.openapi.controller.ApiController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.emm.yixun.common.app.BaseDataReqDto;
import com.emm.yixun.common.app.ProjectsPmoResDto;
import com.emm.yixun.openapi.dto.base.BaseRequestDTO;
import com.emm.yixun.openapi.dto.base.BaseResponseDTO;
import com.emm.yixun.openapi.hander.base.CommonAbstractHander;
import com.emm.yixun.openapi.vo.BaseDataReqVo;
import com.emm.yixun.system.service.BaseCodeValueServiceFacade;
@Service("baseDataHander")
public class BaseDataHander extends CommonAbstractHander {

	private static Logger logger = LoggerFactory.getLogger(ApiController.class);

    @Autowired
    private BaseCodeValueServiceFacade baseCodeValueServiceFacade;
    @SuppressWarnings("rawtypes")
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
	BaseDataReqVo reqVo = (BaseDataReqVo)reqDto;
	List<BaseDataReqDto> params = reqVo.getParams();
	BaseResponseDTO<ProjectsPmoResDto> res = new BaseResponseDTO<ProjectsPmoResDto>();
	try {
	    res.setResData(baseCodeValueServiceFacade.baseline(params,reqVo.getInterfaceName()));
	} catch (Exception e) {
		logger.error("推送业态失败,接口调用异常: ", e);
	    ProjectsPmoResDto projectsPmoResDto = new ProjectsPmoResDto();
	    projectsPmoResDto.setCode("000005");
	    projectsPmoResDto.setDesc("接口调用异常");
	    res.setResData(projectsPmoResDto);
	}
	return res;
    }

}
